<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>5_1_2-定义组件</title>
</head>

<body>


  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <div id="Application">
    <my-alert></my-alert>
    <my-alert></my-alert>
  </div>
  <script>
    const App = Vue.createApp({});
    const alertComponent = {
      data() {
        return {
          msg: "警告标识",
          count: 0,
        };
      },
      methods: {
        click() {
          this.count++;
        },
      },
      template: `<div><button @click="click">按钮{{count}}</button></div>`,
    };
    App.component("my-alert", alertComponent);
    App.mount("#Application");
  </script>
</body>

</html>